#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/sched.h>
#include<linux/mm_types.h>
#include<linux/sched/task.h>
#include<linux/pid.h>
// #include<asm/pgtable_64_types.h>
// #include<asm-generic/pgtable.h>
// #include<asm-generic/page.h>
// #include<asm/paravirt.h>

int init_module(void){
    struct task_struct *ts;
    struct mm_struct *ms;
    unsigned long cr3;
    pgd_t *pgd;
    int i;
    
    printk(KERN_INFO "task_2\n");
    // cr3 = __read_cr3();
    ts = current;
    ms = ts->active_mm;
    pgd = ms -> pgd;
    //CR3寄存器存储的是进程页全局目录的物理基址，然而 task_struct->mm->pgd存储的是进程页全局目录的虚拟地址。
    for(i=0;i<PTRS_PER_PGD;i++){
        pgd_t entry = pgd[i];
        printk(KERN_INFO "PDE Entry %d: %lx\n", i, pgd_val(entry));
    }
    return 0;
}

void cleanup_module(void){
    printk(KERN_INFO "task_2 end\n");
}